<?php
header("content-type:text/html;charset=utf-8");
session_start();			
$getcode = trim($_POST["getcode"]);			
if ($getcode == $_SESSION['VCODE']) {
    include_once './inc/conn.php';
    $title     = trim($_POST['title']);
    $content   = trim($_POST['content']);
	$type      = trim($_POST['type']);
	$corname   = trim($_POST['corname']);
	$corman    = trim($_POST['corman']);
	$cortel    = trim($_POST['cortel']);
	$cormobile = trim($_POST['cormobile']);
	$coremail  = trim($_POST['coremail']);
	$corqq     = trim($_POST['corqq']);
	$coraddr   = trim($_POST['coraddr']);	
    $addtime   = date("Y-m-d H:i:s");
	
	$error    = '';	
	if (empty($title)) {
		$error .= '<font color="red">标题不能为空<br></font>'; 
	}
	
	if (empty($content)) {
		$error .= '<font color="red">内容不能为空<br></font>'; 
	}
	
	if (empty($corman)) {
		$error .= '<font color="red">联系人不能为空<br></font>'; 
	}
    
	if (empty($cormobile)) {
		$error .= '<font color="red">手机号码不能为空<br></font>'; 
	}    
    
	
	if (!empty($error)) {
		echo $error;		
		echo "<script>alert('马上返回');window.history.back();</script>";
		exit;
	}   
	
	switch ($type) {
		case '2':
			$msg = "感谢您的留言，我们会及时查看您的留言";
			break;
		case '1':
			$msg = "感谢您提交问题，客服人员会尽快回答您的问题";
			break;
	}	
   
	$sqlstr = "INSERT INTO ssq_question(questitle,quescontent,quesaddtime,questype,corname,corman,cortel,cormobile,coremail,corqq,coraddr) VALUES ('$title','$content','$addtime','$type','$corname','$corman','$cortel','$cormobile','$coremail','$corqq','$coraddr')";	
	$result = mysql_query($sqlstr) or die(mysql_error());	
	if ($result) {		
		echo "<script>alert('".$msg."');window.history.back();</script>";		
	} else {
		exit("<script>alert('因为网络问题，提交错误啦');window.history.back();</script>");
		}
} else {
    echo "<script>alert('验证码错误，请重新输入！');window.history.back();</script>";
    exit;
}
mysql_close($conn);
?>